Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for flag enums with more than 32 values #1530

Conversation

genne5
Copy link
Contributor

@genne5 genne5 commented Jun 7, 2022

The generator has so far only generated enums with the implicit default type int.
Also for enums declared with the base type long in C# and a "Format = int64" was specified in the OpenAPI document.
Original C#

 public enum Foo : long
    {
        _0 = 0L,
        _1 = 1L << 1,
        _2 = 1L << 2,
       ...
        _31 = 1L << 31,
        _32 = 1L << 32,
        _33 = 1L << 33
    }

Swagger Definition

      "Foo": {
        "type": "integer",
        "format": "int64",
        "description": "",
        "x-enumNames": [
          "_0",
          "_1",
          "_2",
       ...
          "_31",
          "_32",
          "_33"
        ],
        "enum": [
          0,
          2,
          4,
       ...
          2147483648,
          4294967296,
          8589934592
        ]
      }

NSwag Output

 public enum Foo
    {
        _0 = 0,
        _1 = 2,
        _2 = 4,
       ...
        _31 = 2147483648,
        _32 = 4294967296,
        _33 = 8589934592
    }

The nswag output does not compile because "long" is missing as base type.
The values exceed the range of the implicit base type int.

@RicoSuter RicoSuter merged commit a43bed2 into RicoSuter:master Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants